<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>登录页面</title>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
        	$(document).ready(function(){
        		$("button").click(function(){
        			if($("input[name=userName]").val()==""||$("input[name=passWord]").val()==""){
        				alert("请输入用户名或密码");
        				return;
        			}
        			$.ajax({
        				type:"post",
        				url:"signInServlet",
        				async:true,
        				data:$("form").serialize(),
        				success:function(data){
        					if(data=="success"){
        						window.location.href="bbs.jsp";
        					}
        					if(data=="fail"){
        						alert("用户名不存在或是密码错误，请重新输入");
        						window.location.reload();
        					}
        				}
        			});
        		})
        	})
        </script>
    </head>
    <body>
    	<div class="form">
	    	<form>
				<div class="form-group">
				    <label for="exampleInputEmail1">用户名</label>
				    <input type="text" class="form-control" name="userName" placeholder="NickName">
				</div>
				<div class="form-group">
				   	<label for="exampleInputPassword1">密码</label>
				    <input type="password" class="form-control" name="passWord" placeholder="Password">
				</div>
				
			</form>
			<button type="submit" class="btn btn-default">确定</button>
			<span><a href="register.jsp">我要注册</a></span>
		</div>
		<script type="text/javascript">
			$(".form").css({"width":"300px","margin":"auto"});
		</script>
 	</body>
</html>